<template>
  <div>
    <van-sticky>
      <div id="header">好友动态</div>
    </van-sticky>

    <div v-if="status" class="detail" style="margin: 0 0 7vh">
      <article-item v-for="item in data" :key="item.id" :item="item" />
    </div>
    <!-- 底部 -->
    <van-tabbar class="footer" v-model="activeFooter">
      <van-tabbar-item icon="home-o" @click="index">首页</van-tabbar-item>
      <van-tabbar-item icon="chat-o" @click="msg">关注</van-tabbar-item>
      <van-tabbar-item icon="friends-o" @click="friend">好友</van-tabbar-item>
      <van-tabbar-item icon="user-o" @click="mine">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
import ArticleItem from "@/components/ArticleItem.vue";
export default {
  components: { ArticleItem },
  data() {
    return {
      activeFooter: 1,
      stopLoading: false,
      pageNum: 1, //页码
      status: false,
      data: null, //接收首页文章列表数据
      createUser: {
        avatarUrl: "",
        username: "",
      },
      articleDo: {
        imgIds: [],
        masterImg: "",
        id: "",
      },
    };
  },
  methods: {
    index() {
      if (this.$route.path == "/index") return;
      this.$router.push("/index");
    },
    msg() {
      if (this.$route.path == "/msg") return;
      this.$router.push("/msg");
    },
    friend() {
      if (this.$route.path == "/friend") return;
      this.$router.push("/friend");
    },
    mine() {
      if (this.$route.path == "/mine") return;
      this.$router.push("/mine");
    },
  },
  mounted() {
    let url = `/op/articleDo/getArticleList?pageNum=1&type=1`;
    this.axios
      .get(url, {
        "Context-Type": "application/json",
        headers: { accesstoken: this.$store.state.accesstoken },
      })
      .then((res) => {
        console.log("首页文章列表:", res);
        console.log("accesstoken:", this.$store.state.accesstoken);
        this.data = res.data.data.articleList;

        // this.articleDo = this.res.data.data.articleList.articleDo
        // this.createUser = this.res.data.data.articleList.createUser
        this.status = true;
      });
  },
};
</script>

<style lang="scss" scoped>
.detail {
  display: flex;
  justify-content: space-evenly;
  flex-wrap: wrap;
  > .article-item {
    margin: 2vw;
    width: 42vw;
  }
}
#header {
  line-height: 7vh;
  font-size: 4.5vw;
  color: rgb(231, 36, 10);
  background-color: rgba(245, 212, 169);
  text-align: center;
}

.mint-cell {
  background-color: rgb(226, 180, 95);
}

// ::v-deep .van-tabs__nav {
//   height: 2.5rem;
// }
.item {
  background-color: rgba(245, 212, 169);
  overflow: hidden;
  display: flex;
  flex-wrap: wrap;
}
.footer {
  background-color: rgba(245, 212, 169);
}
.van-tabbar-item--active {
  background-color: rgba(245, 212, 169);
  color: rgb(233, 109, 51);
}
</style>
